Wrap `cargo run` `ProcessError` in `Human` if the exit code is non-zero
authorGleb Kozyrev <gleb@gkoz.com>
Wed, 14 Oct 2015 20:08:29 +0000 (23:08 +0300)
committerGleb Kozyrev <gleb@gkoz.com>
Wed, 14 Oct 2015 21:31:04 +0000 (00:31 +0300)
src/bin/run.rs
tests/test_cargo_run.rs

index 838ac4655f93cbfd9aeba7561e46dfa3755df5a8..d765967ddda8ae2fa8588ab407b5e9b533bb838f 100644 (file)
@@ -1,5 +1,5 @@
 use cargo::ops;
-use cargo::util::{CliResult, CliError, Config, human};
+use cargo::util::{CliResult, CliError, Config, Human};
 use cargo::util::important_paths::{find_root_manifest_for_cwd};
 
 #[derive(RustcDecodable)]
@@ -92,10 +92,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         None => Ok(None),
         Some(err) => {
             Err(match err.exit.as_ref().and_then(|e| e.code()) {
-                Some(code) => {
-                    let desc = format!("Process finished with exit status {}", code);
-                    CliError::from_boxed(human(desc), code)
-                }
+                Some(code) => CliError::from_error(Human(err), code),
                 None => CliError::from_error(err, 101),
             })
         }
index f2dab301cb3cb9a1ab2931f1e83c140dc2a72dc9..11a9d9311427bf5849cfe845b8878414c7adf934 100644 (file)
@@ -104,7 +104,7 @@ test!(exit_code {
     assert_that(p.cargo_process("run"),
                 execs().with_status(2)
                        .with_stderr(&format!("\
-Process finished with exit status 2
+Process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
 ",
         )));
 });
@@ -124,7 +124,7 @@ test!(exit_code_verbose {
     assert_that(p.cargo_process("run").arg("-v"),
                 execs().with_status(2)
                        .with_stderr(&format!("\
-Process finished with exit status 2
+Process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
 ",
         )));
 });